export default {
  beforeMount () {
    const { query } = this.$route
    // 路由上的query与data中绑定
    for (let [key, value] of Object.entries(query)) {
      if (this.query.hasOwnProperty(key)) {
        this.query[key] = isNaN(value) ? value : Number(value)
      }
    }
    // this.fetchList(this.query)
  },
  methods: {
    filterForm (data) {
      let form = {}
      for (let [key, value] of Object.entries(this.formDefault)) {
        if (this.formDefault.hasOwnProperty(key)) {
          form[key] = data[key] || value
        }
      }
      return form
    },
    onSubmit () {
      this.query.page = 1
      this.fetchList(this.query)
    },
    onReset () {
      this.query = { ...this.$options.data().query }
      this.fetchList(this.query)
    },
    onPage (page) {
      this.query.page = page
      this.fetchList(this.query)
    }
  }
}
